package cn.virens.web.controller.manage.sys;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.virens.common.RequestUtil;
import cn.virens.database.enums.MessageState;
import cn.virens.database.enums.MessageType;
import cn.virens.database.mysql.model.sys.SysMessage;
import cn.virens.database.service.sys.SysMessageService;
import cn.virens.web.common.BaseTableController;

/**
 * 消息管理 - sys_message
 *
 * @author Virens
 * @since  2018-08-25 15:38:28
 */
@Controller
@RequestMapping("/manage/sys/message")
public class SysMessageContorller extends BaseTableController<SysMessage, SysMessageService> {

	public SysMessageContorller() {
		super("/manage/sys/message", "sys:message");
	}

	@Override
	public String index(HttpServletRequest request, HttpServletResponse response, Model model) {
		String answer = super.index(request, response, model);
		model.addAttribute("states", MessageState.values());
		model.addAttribute("types", MessageType.values());

		return answer;
	}

	@RequestMapping("view.jspx")
	public String viewJspx(HttpServletRequest request, HttpServletResponse response, Model model) {
		model.addAttribute("record", mBaseService.selectOne(RequestUtil.getValueInt(request, "id")));

		return returnUrl("view");
	}

	@RequestMapping("create.jspx")
	public String createJspx(HttpServletRequest request, HttpServletResponse response, Model model) {
		return returnUrl("create");
	}

}
